
//
//  CZMainViewController.swift
//  Swift -- 微博
//
//  Created by sks on 16/6/25.
//  Copyright © 2016年 mohaha. All rights reserved.
//

import UIKit

class CZMainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        //给控制器设置自定义tabBar
        let tabBar = CZTabBar()
        tabBar.CZDelegate = self
        setValue(tabBar, forKey: "tabBar")
        
        addChildViewController(CZHomeViewController(), title: "首页", imageName: "tabbar_home")
        addChildViewController(CZMessageViewController(), title: "消息", imageName: "tabbar_message_center")
        addChildViewController(CZDiscoverViewController(), title: "发现", imageName: "tabbar_discover")
        addChildViewController(CZProfileViewController(), title: "我", imageName: "tabbar_profile")

    }
    
    func addChildViewController(vc:UIViewController,title:String,imageName:String)  {
        
        vc.title = title
        
        vc.tabBarItem.image = UIImage(named: imageName)
        vc.tabBarItem.selectedImage = UIImage(named: "\(imageName)_selected")
        
        let navc = UINavigationController(rootViewController: vc)
        
        addChildViewController(navc)
        
    }
    
}

extension CZMainViewController : CZTabBarDelegate{
    
    func composeBtnClick() {
        
        print("弹出控制器")
    }
    
}
